package com.znzz.service.impl;

import com.znzz.dao.FilesDao;
import com.znzz.entity.Files;
import com.znzz.service.FilesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service()
public class FilesServiceImpl implements FilesService {

    @Autowired
    private FilesDao filesDao;


    @Override
    public boolean saveFiles(Files files) {
        return filesDao.saveFiles(files);
    }

    @Override
    public Integer getFilesCountById() {
        return filesDao.getFilesCountById();
    }

    @Override
    public List<Files> getFilesById4Page(Integer pageNumber, Integer pageSize) {
        Integer recordBegin = (pageNumber-1)*pageSize;
        if(recordBegin<0)
            recordBegin = 0;

        return filesDao.getFilesById4Page(recordBegin, pageSize);
    }

    @Override
    public Files getFilesById(Integer id) {
        return filesDao.getFilesById(id);
    }

    @Override
    public boolean updatedownloadCount(Files files) {
        return filesDao.updatedownloadCount(files);
    }

    @Override
    public boolean deleteFile(Integer id) {
        return filesDao.deleteFile(id);
    }


}
